package com.npjscg.medicalpro.mapper;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Constants;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.npjscg.medicalpro.controller.dto.TemplateDTO;
import com.npjscg.medicalpro.entity.Template;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author raote
 * @since 2022-06-28
 */
public interface TemplateMapper extends BaseMapper<Template> {

    @Select("SELECT * FROM t_template AS tem  left JOIN (SELECT * FROM t_report WHERE t_report.uid =#{uid}) AS report ON tem.id = report.tid WHERE report.id is null and tem.tem_name like #{temname}")
    Page<Template> selectUnCompletePage(@Param("page") Page<Template> page, String temname , int uid);

    @Select("SELECT COUNT(*) FROM t_report as re RIGHT JOIN (SELECT * FROM t_check WHERE status = #{i}) AS ch ON re.id = ch.rid WHERE re.tid = #{id}")
    Integer getData(int i, int id);
}
